package example1;

import java.util.Arrays;

public class StaticProxy {
    public static void main(String[] args) {

        You you=new You();

        // 使用lambda表达式实现runnbale接口
        new Thread(()-> System.out.println("我爱你")).start();

        new WeddingCompany(new You()).marry();
    }
}

interface Marry{
    void marry();
}

// 真实角色
class You implements Marry{

    @Override
    public void marry() {
        System.out.println("happy");
    }
}

// 代理角色
class WeddingCompany implements Marry{

    private Marry target;

    public WeddingCompany(Marry target){
        this.target=target;
    }
    @Override
    public void marry() {
        before();
        this.target.marry();  // 真实对象
        after();
    }

    private void after() {
        System.out.println("结婚之后收尾款");
    }

    private void before() {
        System.out.println("结婚之前布置现场");
    }
}